<!--项目退领管理页-->

<template>
  <div>
    <el-card class="shang">
    <el-form :inline="true" :model="keyword" ref="searchForm" class="demo-form-inline">
      <div>
      <el-form-item label="编号">
        <el-input style="width: 300px" v-model="keyword.id" placeholder="项目编号"></el-input>
      </el-form-item>
      <el-form-item label="项目名称">
        <el-select style="width: 300px" v-model="keyword.name" placeholder="请选择">
          <el-option label="樱花园区改造智能化工程" value="樱花园区改造智能化工程"></el-option>
          <el-option label="花花牛产业园改造智能化工程" value="花花牛产业园改造智能化工程"></el-option>
          <el-option label="大白兔奶糖智能化工程" value="大白兔奶糖智能化工程"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="劳务单位">
        <el-select style="width: 300px" v-model="keyword.unit" placeholder="请选择">
          <el-option label="樱花园区" value="shanghai"></el-option>
          <el-option label="花花牛产业园" value="beijing"></el-option>
          <el-option label="大白兔奶糖" value="guangzhou"></el-option>
        </el-select>
      </el-form-item>
      </div>
      <div>
      <el-form-item label="类型">
        <el-select style="width: 300px" v-model="keyword.kind" placeholder="请选择">
          <el-option label="领用" value="领用"></el-option>
          <el-option label="退还" value="退还"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="项目人员">
        <el-select style="width: 300px" v-model="keyword.rname" placeholder="请选择">
          <el-option label="王五" value="王五"></el-option>
          <el-option label="段问薇" value="段问薇"></el-option>
          <el-option label="潘周丹" value="潘周丹"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="签名状态">
        <el-select style="width: 300px" v-model="keyword.sig" placeholder="请选择">
          <el-option label="已签名" value="已签名"></el-option>
          <el-option label="未签名" value="未签名"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="search">查询</el-button>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="resetSearchForm('searchForm')">重置</el-button>
      </el-form-item>
      </div>
      <div>

        <el-form-item>
          <el-button type="success" @click="dialogFormVisible = true">新增领用</el-button>

          <el-dialog title="新增领用" :visible.sync="dialogFormVisible">
            <el-form :model="form">
              <el-form-item label="项目名称">
                <el-select v-model="form.name" placeholder="樱花园区改造智能化工程">
                  <el-option label="樱花园区改造智能化工程" value="樱花园区改造智能化工程"></el-option>
                  <el-option label="花花牛产业园改造智能化工程" value="花花牛产业园改造智能化工程"></el-option>
                  <el-option label="大白兔奶糖智能化工程" value="大白兔奶糖智能化工程"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="劳务单位">
                <el-select v-model="form.unit" placeholder="樱花园区">
                  <el-option label="樱花园区" value="樱花园区"></el-option>
                  <el-option label="花花牛产业园" value="花花牛产业园"></el-option>
                  <el-option label="大白兔奶糖" value="大白兔奶糖"></el-option>
                </el-select>
              </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
              <el-button @click="dialogFormVisible = false">取 消</el-button>
              <el-button type="primary" @click="handle1">确 定</el-button>
            </div>
          </el-dialog>
          <el-button type="success" @click="handle2" style="margin-left:10px">新增退还</el-button>
          <el-button type="success" @click="handle3">项目仓库</el-button>
        </el-form-item>
        <el-dialog title="弹窗" :visible.sync="detailVisible" width="35%">
          弹窗内容
        </el-dialog>
      </div>
    </el-form>
    </el-card>

    <el-card class="xia">
    <el-table :data="glList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column prop="id" label="编号" align="center"/>
      <el-table-column prop="name" label="项目名称" align="center"/>
      <el-table-column prop="unit" label="劳务单位" align="center"/>
      <el-table-column prop="rname" label="项目人员" align="center"/>
      <el-table-column prop="kind" label="类型" align="center"/>
      <el-table-column prop="updateTime" label="更新时间" align="center"/>
      <el-table-column prop="sig" label="签名状态" align="center"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" icon="el-icon-view" @click="handle">查看</el-button>
          <el-button type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>


    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[5, 10, 20]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
    </el-card>
  </div>
</template>
<script>
import { getList, delById } from "@/api/gl";
import {title} from "@/settings";
import form from "element-ui/packages/form";

export default {
  computed: {
    form() {
      return form
    }
  },
  data() {
    return {
      form:{
        name: null,
      },
      loading: true,
      glList: [],
      pageNum: 1,
      pageSize: 5,
      currentPage: 1,
      total: 0,
      keyword: {
        id: null,
        name: null,
        unit: null,
        rname: null,
        kind: null,
        updateTime: null,
        sig: null
      },
      ids:[],
      title: '',
      dialogFormVisible: false,
      wmsGl: {
        id: null,
        name: null,
        unit: null,
        rname: null,
        kind: null,
        updateTime: null,
        sig: null
      },
      wmsPmRules: {
        id: [
          { required: true, message: '编号不能为空', trigger: 'blur' }
        ],
        name: [
          { required: true, message: '项目名称不能为空', trigger: 'blur' }
        ],
      }
    }
  },
  methods: {
    handle() {
      this.$router.push({name: 'Look'})
    },
    open() {
      this.$alert('这是一段内容', '新增领用', {
        confirmButtonText: '确定',
        callback: action => {
          this.$message({
            type: 'info',
            message: `action: ${ action }`
          });
        }
      });
    },
    handle1(){
      // console.log("项目名称:",this.keyword.name,"劳务单位:",this.keyword.unit,"项目人员:")
      this.$router.push({name: 'Tl'})
    },
    handle2(){
      this.$router.push({name: 'Th'})
    },
    handle3(){
      this.$router.push({name: 'Ck'})
    },
    title() {
      return title
    },
    fetchData() {
      let params = {
        pageNum:this.pageNum,
        pageSize:this.pageSize,
        id:this.keyword.id,
        name:this.keyword.name,
        unit:this.keyword.unit,
        rname:this.keyword.rname,
        kind:this.keyword.kind,
        updateTime:this.keyword.updateTime,
        sig:this.keyword.sig
      }
      getList(params).then(res => {
        this.glList = res.data.list
        this.total = res.data.total
        this.pageSize = res.data.pageSize
      })
    },
    // 多选框中的数据
    handleSelectionChange(selectionRowArr) {
      this.ids = [];
      for (let i = 0; i < selectionRowArr.length; i++) {
        this.ids.push(selectionRowArr[i].id)
      }
    },
    // 页面大小改变时触发
    handleSizeChange(val) {
      this.pageSize = val;
      this.fetchData();
    },
    // 当前页面改变时触发
    handleCurrentChange(val) {
      this.pageNum = val;
      this.fetchData();
    },
    // 模糊搜索
    search() {
      this.fetchData()
    },
    // 重置
    resetSearchForm(formName) {
      this.$refs[formName].resetFields();
      this.keyword={}
      this.fetchData()
    },

    // 删除
    handleDelete(row) {
      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let params = {
          id:row.id
        }
        delById(params).then(res => {
          this.$message({
            message: '删除成功',
            type: 'success'
          })
          this.fetchData()
        })
      })
    }
  },
  created() {
    this.fetchData()
  }
}
</script>


<style scoped>
.shang {
  margin-top: 30px;
  margin-left: 30px;
  margin-right: 30px;
}
.xia {
  margin-top: 30px;
  margin-left: 30px;
  margin-right: 30px;
}
</style>
